/* Sidebar Sections */
.sidebar-section {
  margin-bottom: 20px !important;
  background: var(--card);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.sidebar-section:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px !important;
  background: linear-gradient(135deg, rgba(79,70,229,0.02) 0%, rgba(16,185,129,0.02) 100%);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}

.sidebar-section-header:hover {
  background: linear-gradient(135deg, rgba(79,70,229,0.05) 0%, rgba(16,185,129,0.05) 100%);
}

.sidebar-section-header h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-section-header h3 span {
  font-size: 1.2rem;
}

.sidebar-section-header .collapse-icon {
  font-size: 1rem;
  color: var(--text-muted);
  transition: transform 0.3s ease;
}

.sidebar-section-header.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.sidebar-section-content {
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  max-height: 1000px;
  padding: 16px;
}

.sidebar-section-content.collapsed {
  max-height: 0 !important;
  padding: 0 16px !important;
}

/* Section color accents */
.sidebar-section[data-section="nav"] .sidebar-section-header {
  border-left: 4px solid #3498db;
}
.sidebar-section[data-section="stats"] .sidebar-section-header {
  border-left: 4px solid #2ecc71;
}
.sidebar-section[data-section="stories"] .sidebar-section-header {
  border-left: 4px solid #f39c12;
}
.sidebar-section[data-section="heatmap"] .sidebar-section-header {
  border-left: 4px solid #9b59b6;
}
.sidebar-section[data-section="theme"] .sidebar-section-header {
  border-left: 4px solid #e74c3c;
}

/* Class stats card - neat design */
.sidebar-stats {
  background: var(--bg) !important;
  border-radius: 12px !important;
  padding: 16px !important;
  border: 1px solid var(--border);
  margin-bottom: 0 !important;
}

.sidebar-stats h3 {
  font-size: 0.9rem !important;
  margin-bottom: 12px !important;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0 !important;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-value {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 12px;
  border-radius: 30px;
}

/* Stories section */
.stories-section {
  background: var(--bg) !important;
  border: 1px solid var(--border);
  border-radius: 12px !important;
  padding: 16px !important;
  margin-bottom: 0 !important;
}

.stories-section h3 {
  font-size: 0.9rem !important;
  margin-bottom: 12px !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.story-item {
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
  cursor: pointer;
}

.story-item:hover {
  transform: translateX(4px);
  border-color: var(--accent);
  background: var(--accent-light);
}

.story-name {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.story-quote {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Heatmap section */
.heatmap-section {
  background: var(--bg) !important;
  border: 1px solid var(--border);
  border-radius: 12px !important;
  padding: 16px !important;
  margin-bottom: 0 !important;
}

.heatmap-section h3 {
  font-size: 0.9rem !important;
  margin-bottom: 12px !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.heatmap-cell {
  width: 100%;
  padding-top: 100%;
  border-radius: 4px;
  background: var(--border);
  position: relative;
}

.heatmap-cell.level-0 { background: rgba(148, 163, 184, 0.25); }
.heatmap-cell.level-1 { background: rgba(16, 185, 129, 0.25); }
.heatmap-cell.level-2 { background: rgba(16, 185, 129, 0.5); }
.heatmap-cell.level-3 { background: rgba(16, 185, 129, 0.75); }
.heatmap-cell.level-4 { background: rgba(16, 185, 129, 0.95); }

/* Theme selector */
.theme-selector {
  width: 100%;
  padding: 12px !important;
  border-radius: 12px !important;
  border: 1px solid var(--border) !important;
  background: var(--bg) !important;
  color: var(--text) !important;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Sidebar spacing */
.sidebar {
  padding: 20px !important;
}

.sidebar-header {
  margin-bottom: 24px !important;
  text-align: center;
}

.class-switcher {
  margin-bottom: 24px !important;
}

.sidebar-nav {
  margin: 0 !important;
}

/* Animation */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sidebar-section-content:not(.collapsed) {
  animation: slideDown 0.3s ease;
}

/* ===== RESPONSIVE & MODERN POLISH ===== */
/* Clean scrollbars */
.sidebar::-webkit-scrollbar,
.main-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.sidebar::-webkit-scrollbar-track,
.main-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb,
.main-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.main-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .stat-card:hover,
  .btn:hover,
  .nav-item:hover,
  .content-card:hover {
    transform: none !important;
  }
}

/* Mobile safe areas */
@supports (padding: max(0px)) {
  @media (max-width: 767px) {
    .main-content {
      padding-left: max(var(--spacing-md), env(safe-area-inset-left)) !important;
      padding-right: max(var(--spacing-md), env(safe-area-inset-right)) !important;
      padding-bottom: max(var(--spacing-md), env(safe-area-inset-bottom)) !important;
    }
  }
}